'''
鼠标操作的方法：
(1)perform()			执行所有ActionChains中存储的行为
(2)double_click()		鼠标左键双击
(3)context_click()	鼠标右键单击
(4)move_to_element()				鼠标悬停
(5)drag_and_drop(source，target)	鼠标拖动
(6)	key_down()  键按下
(7)	key_up()    键抬起
(8)实现思路：
①需要引入ActionChains类
②然后定位相关元素
③初始化ActionChains()对象，调用相关鼠标操作方法，然后执行


'''
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
from options import options
from service import service

dr=webdriver.Chrome(options=options,service=service)
dr.get(r'https://www.baidu.com/')

# 鼠标左键双击
# dr.find_element(By.ID,'kw').send_keys('aaaa')
# ele=dr.find_element(By.ID,'kw')
# ActionChains(dr).double_click(ele).perform()
# sleep(3)
# # 鼠标右键单击
# dr.find_element(By.ID,'kw').send_keys('aaaa')
# ele=dr.find_element(By.ID,'kw')
# ActionChains(dr).context_click(ele).perform()
# sleep(3)

# 鼠标悬停
ele=dr.find_element(By.NAME,'tj_briicon')
ActionChains(dr).move_to_element(ele).perform()
sleep(3)

# 鼠标拖动
ele1 = dr.find_element(By.ID, 'value1')
ele2 = dr.find_element(By.ID, 'value2')
ActionChains(dr).drag_and_drop(ele1, ele2).perform()
sleep(3)

dr.quit()
